<template>
  <diV>
    <h2>this is login page</h2>username:
    <input type="text" name="username" v-model="loginForm.username">
    <br>
    <br>
    <br>password:
    <input type="text" name="password" v-model="loginForm.password">
    <br>
    <br>
    <br>
    <button @click="login">登录</button>
  </diV>
</template>
<script>
export default {
  data() {
    return {
      loginForm: {
        username: "zhangsan",
        password: 123456
      }
    };
  },
  methods: {
    login: function() {
      alert(this.loginForm.username + "==" + this.loginForm.password);
      this.$http
        .post("login", {
          username: this.loginForm.username,
          password: this.loginForm.password
        })
        .then(response => {
          //登录成功
          console.log(response);
          this.$router.push("/main");
        })
        .catch(error => {
          console.log(error);
        });
    }
  }
};
</script>
<style>
</style>


